import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/views/Layout'
import Login from '@/views/Login'
import Category from '@/views/Category'
import Home from '@/views/Home'// 引入home组件
import Good from '@/views/Good'
import Cart from '@/views/Cart'
import Settle from '@/views/Settle'
import Pay from '@/views/pay'
const routes = [
  {
    path: '/login', // 一级路由登录页
    component: Login
  },
  {
    path: '/', // 一级路由首页
    component: Layout,
    children: [// 二级路由分类页
      {
        path: '', // 如果二级路由path为空将作为默认渲染的路由
        component: Home
      },
      {
        name: 'category',
        path: 'category/:id',
        component: Category
      },
      {
        path: '/good/:id',
        component: Good
      },
      {
        path: 'cart',
        component: Cart
      },
      {
        path: 'settle',
        component: Settle
      },
      {
        path: '/pay',
        component: Pay
      }
    ]
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
